package edu.ntnu.superrss.models;

import com.sun.syndication.feed.synd.SyndEntry;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;

/**
 * POJO with Hibernate Annotations
 * @author Dyre <dyre.hult at gmail.com>
 */
@Entity
@Table(name = "Comment")
public class Comment implements Serializable {

    private Long id;
    private String content;
    private Date publishedDate;
    private SyndEntryImpl entrysource;
    private User user = new User();

    public Comment() {
    }

    public Comment(String content) {
        this.content = content;
    }

    @Id
    @GeneratedValue
    @Column(name = "ID")
    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
       this.id = id;
    }

    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    public Date getPublishedDate() {
        return publishedDate;
    }

    public void setPublishedDate(Date publishedDate) {
        this.publishedDate = publishedDate;
    }

    @ManyToOne(targetEntity=SyndEntryImpl.class,cascade=CascadeType.ALL)
    public SyndEntryImpl getEntrysource() {
        return entrysource;
    }

    public void setEntrysource(SyndEntryImpl entrysource) {
        this.entrysource = entrysource;
    }

    @Column(name = "CONTENT")
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @OneToOne(targetEntity = User.class, cascade = CascadeType.ALL)
    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
